Skip to content

fix: skip retries for HTTP 429 error 1113#76

Open
z116123123x wants to merge 1 commit into
zai-org:mainfrom
z116123123x:fix/non-retryable-arrears-429
Open

fix: skip retries for HTTP 429 error 1113#76
z116123123x wants to merge 1 commit into
zai-org:mainfrom
z116123123x:fix/non-retryable-arrears-429

Conversation

@z116123123x

Copy link
Copy Markdown

Description

Z.AI returns HTTP 429 for both retryable throttling conditions and business
errors. The SDK currently retries every HTTP 429 response, so business error
1113 (account in arrears; recharge required) causes repeated requests even
though it requires an account-state change to recover.

This change:

  • reads the documented business error code from error.code;
  • skips automatic retries only for HTTP 429 error 1113;
  • preserves explicit x-should-retry overrides;
  • keeps other HTTP 429 responses, including error 1305, retryable;
  • reads streamed error responses before classification so the existing
    APIReachLimitError still contains the response body.

For SDK users, error 1113 now raises the existing APIReachLimitError
immediately instead of waiting through automatic retries. There is no public
API change.

Reference: Z.AI error codes

Verification

  • make test: 68/68 passed locally with Poetry 1.8.2 on Python 3.9,
    3.10, 3.11, and 3.12
  • Targeted retry-policy tests: 7/7 passed on Python 3.8
  • Ruff 0.1.15 passed for the added test file
  • git diff --check passed
  • Source distribution and wheel built successfully
  • No live or paid API request was made

The full Python 3.8 suite was not completed locally because the locked DuckDB
dependency fell back to a long source build on macOS arm64. The targeted Python
3.8 tests pass, and the repository's Ubuntu CI will run the full Python 3.8
job.

Checklist

  • Followed the current CONTRIBUTING guide
  • Used a Conventional Commit PR title
  • Ran the applicable unit tests with make test
  • Reviewed documentation impact; no documentation update is required
    because this changes internal retry classification without changing the
    public API

@z116123123x
z116123123x marked this pull request as ready for review July 14, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant